package com.shipwe.loans.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.shipwe.adapter.ShipweRecyclerViewAdapter
import com.shipwe.adapter.ShipweViewHolderHelper
import com.shipwe.loans.R
import com.shipwe.loans.utils.AppLoadImageUtil
import org.json.JSONObject

/**
 * Shipwe
 * @Author wwdeng
 * @CreateTime: 2024/11/27 13:45
 * @Annotation：意见反馈 - 图片列表
 */
class UserAdviseImageAdapter(recyclerView: RecyclerView?): ShipweRecyclerViewAdapter<JSONObject>(recyclerView) {

    override fun getItemViewType(position: Int): Int {
        val model = getItem(position)
        if (model.optBoolean("isDefault",true)){
            return R.layout.activity_user_advise_add_item
        }
        return R.layout.activity_user_advise_image_item
    }
    override fun setItemChildListener(helper: ShipweViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.userAdviseImgRemove) //删除
        helper.setItemChildClickListener(R.id.userAdviseImgAdd)//选择
    }

    override fun fillData(helper: ShipweViewHolderHelper, position: Int, model: JSONObject) {
        //是否是默认图片
        if (!model.optBoolean("isDefault",true)){
            val userAdviseImg = helper.getImageView(R.id.userAdviseImg)
            AppLoadImageUtil.instance.loadImageUrl(mContext,userAdviseImg,model.optString("imgPath"))
        }
    }
}